<?php
/************************
 *  Codenova.pl Project
 *  Created by: Kamil Mrzygłód
 *
 *  (c) 2013 by Codenova.pl
 *  All Right Reserved
 ***********************/

namespace Gotcha\App\Extensions;

// Gotcha cultures class

use Gotcha\App\Types\Arrays;
use Gotcha\App\Types\String;

final class CulturesExtension extends FileSystemExtension {
    static public function getTranslation(String $translationId) {
        // Get current culture
        $currentApplicationCulture = (string)parent::xmlFileHandler(new String('\App\Config\config.xml'), new String('defaultculture'));

        // Make sure culture file exists
        if (parent::CheckFileExistence(new String($currentApplicationCulture.'.xml'), new String('App/Cultures/')) === true) {
            // If file exists we can load a translation connected with 
			// given id
			return parent::processCultureFile($translationId, new String('\App\Cultures\\'.$currentApplicationCulture.'.xml'));
        } else {
            ErrorsExtension::throwErrorAndSaveLogWithoutCulture(new String('Chosen culture file %s doesn\'t exist.'), new Arrays(array(new String($currentApplicationCulture.'.xml'))));
        }

        return null;
    }
}